home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Environments
/
PowerMacOberon feb96
/
Source
/
Display.Mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1994-07-26
|
9KB
|
181 lines
Syntax10.Scn.Fnt
StampElems
Alloc
26 Jul 94
MODULE Display; (*mf 9.3.93/ mah
IMPORT
SYS:=SYSTEM, Macintosh, Sys;
CONST
black*=0; white*=15;
replace*=0; paint*=1; invert*=2;
Pattern*=LONGINT;
Font*=POINTER TO Bytes;
Bytes*=RECORD END; (* really: Macintosh.FontMap *)
Frame*=POINTER TO FrameDesc;
FrameMsg*=RECORD END;
Handler*=PROCEDURE(f: Frame; VAR msg: FrameMsg);
FrameDesc*=RECORD
dsc*, next*: Frame;
X*, Y*, W*, H*: INTEGER;
handle*: Handler
END;
Unit*: LONGINT;
Left*, ColLeft*, Bottom*, UBottom*, Width*, Height*: INTEGER;
arrow*, star*, hook*, cross*, downArrow*, grey0*, grey1*, grey2*, ticks*: Pattern;
(* Display Procedures *)
PROCEDURE Map*(x: INTEGER): LONGINT;
BEGIN RETURN SYS.VAL(LONGINT, Macintosh.thePortPtr)
END Map;
PROCEDURE SetMode*(x: INTEGER; s: SET);
END SetMode;
(* Color Display *)
PROCEDURE SetColor*(col, red, green, blue: INTEGER);
BEGIN Macintosh.SetColor(col, red, green, blue)
END SetColor;
PROCEDURE GetColor*(col: INTEGER; VAR red, green, blue: INTEGER);
BEGIN Macintosh.GetColor(col, red, green, blue)
END GetColor;
(* Fonts / Patterns *)
PROCEDURE GetChar*(f: Font; ch: CHAR; VAR dx, x, y, w, h: INTEGER; VAR p: LONGINT);
BEGIN Macintosh.GetChar(SYS.VAL(LONGINT, f), ch, dx, x, y, w, h, p)
END GetChar;
PROCEDURE NewPattern*(VAR image: ARRAY OF SET; w, h: INTEGER): Pattern;
VAR i, j : INTEGER; s : SET;
BEGIN
i:=SHORT (LEN (image));
WHILE i>0 DO
DEC (i); s:={};
FOR j:=0 TO 31 DO IF j IN image[i] THEN INCL (s, 31-j) END END;
image[i]:=s
END;
RETURN SYS.VAL(Pattern, Macintosh.NewPatMap(image, w, h, 1))
END NewPattern;
(* Auxiliary *)
PROCEDURE Copy(sx, sy, w, h, dx, dy: INTEGER);
VAR port: Sys.GrafPtr;
BEGIN port:=SYS.VAL (Sys.GrafPtr, Macintosh.thePortPtr);
IF sy<=Height THEN
IF dy<=Height THEN Macintosh.CopyBlock(port, port, sx, sy, w, h, dx, dy, w, h)
ELSE Macintosh.CopyBlock(port, Macintosh.shadowPortPtr, sx, sy, w, h, dx, dy, w, h) END
ELSIF dy<=Height THEN Macintosh.CopyBlock(Macintosh.shadowPortPtr, port, sx, sy, w, h, dx, dy, w, h)
ELSE Macintosh.CopyBlock(Macintosh.shadowPortPtr, Macintosh.shadowPortPtr, sx, sy, w, h, dx, dy, w, h) END
END Copy;
(* RasterOps *)
PROCEDURE CopyBlock*(sx, sy, w, h, dx, dy, mode: INTEGER);
BEGIN Macintosh.SetPenScreen(dy>=0, Macintosh.thePortClip, white, mode); Copy(sx, Height-sy, w, h, dx, Height-dy)
END CopyBlock;
PROCEDURE CopyPattern*(col: INTEGER; pat: Pattern; x, y, mode: INTEGER);
BEGIN Macintosh.CopyPatternScreen(y>=0, Macintosh.thePortClip, col, pat, x, Height-y, mode)
END CopyPattern;
PROCEDURE ReplPattern*(col: INTEGER; pat: LONGINT; x, y, w, h, mode: INTEGER);
BEGIN Macintosh.SetPenScreen(y>=0, Macintosh.thePortClip, col, mode); Macintosh.ReplPattern(pat, x, Height-y, w, h)
END ReplPattern;
PROCEDURE ReplConst*(col, x, y, w, h, mode: INTEGER);
BEGIN
Macintosh.SetPenScreen(y>=0, Macintosh.thePortClip, col, mode);
Macintosh.ReplConst(x, Height-y, w, h)
END ReplConst;
PROCEDURE Dot*(col: INTEGER; x, y, mode: INTEGER);
BEGIN Macintosh.SetPenScreen(y>=0, Macintosh.thePortClip, col, mode); Macintosh.Dot(x, Height-1-y)
END Dot;
(* RasterOps with Clipping *)
PROCEDURE CopyBlockC*(F: Frame; sx, sy, w, h, dx, dy, mode: INTEGER);
BEGIN Macintosh.SetUserClip(F.X, Height-F.Y, F.W, F.H);
Macintosh.SetPenScreen(F.Y>=0, Macintosh.userClip, white, mode); Copy(sx, Height-sy, w, h, dx, Height-dy)
END CopyBlockC;
PROCEDURE CopyPatternC*(F: Frame; col: INTEGER; pat: Pattern; x, y, mode: INTEGER);
BEGIN Macintosh.SetUserClip(F.X, Height-F.Y, F.W, F.H);
Macintosh.CopyPatternScreen(F.Y>=0, Macintosh.userClip, col, pat, x, Height-y, mode)
END CopyPatternC;
PROCEDURE ReplPatternC*(F: Frame; col: INTEGER; pat: LONGINT; x, y, w, h, xp, yp, mode: INTEGER);
BEGIN Macintosh.SetUserClip(F.X, Height-F.Y, F.W, F.H);
Macintosh.SetPenScreen(F.Y>=0, Macintosh.userClip, col, mode); Macintosh.ReplPattern(pat, x, Height-y, w, h)
END ReplPatternC;
PROCEDURE ReplConstC*(F: Frame; col, x, y, w, h, mode: INTEGER);
BEGIN Macintosh.SetUserClip(F.X, Height-F.Y, F.W, F.H);
Macintosh.SetPenScreen(F.Y>=0, Macintosh.userClip, col, mode); Macintosh.ReplConst(x, Height-y, w, h)
END ReplConstC;
PROCEDURE DotC*(F: Frame; col: INTEGER; x, y, mode: INTEGER);
BEGIN Macintosh.SetUserClip(F.X, Height-F.Y, F.W, F.H);
Macintosh.SetPenScreen(F.Y>=0, Macintosh.userClip, col, mode); Macintosh.Dot(x, Height-1-y)
END DotC;
(* Initialization *)
PROCEDURE InitPat;
VAR img: ARRAY 17 OF SET;
BEGIN
img[1]:={13}; img[2]:={12..14}; img[3]:={11..13}; img[4]:={10..12};
img[5]:={9..11}; img[6]:={8..10}; img[7]:={7..9}; img[8]:={0, 6..8};
img[9]:={0, 1, 5..7}; img[10]:={0..2, 4..6}; img[11]:={0..5}; img[12]:={0..4};
img[13]:={0..5}; img[14]:={0..6}; img[15]:={0..7};
arrow:=NewPattern(img, 15, 15);
img[1]:={0..7}; img[2]:={0..6}; img[3]:={0..5}; img[4]:={0..4};
img[5]:={0..3}; img[6]:={0..2}; img[7]:={0..1}; img[8]:={0};
hook:=NewPattern(img, 8, 8);
img[1]:={0, 10}; img[2]:={1, 9}; img[3]:={2, 8}; img[4]:={3, 7};
img[5]:={4, 6}; img[6]:={}; img[7]:={4, 6}; img[8]:={3, 7};
img[9]:={2, 8}; img[10]:={1, 9}; img[11]:={0, 10};
cross:=NewPattern(img, 11, 11);
img[1]:={6}; img[2]:={5..7}; img[3]:={4..8}; img[4]:={3..9};
img[5]:={2..10}; img[6]:={5..7}; img[7]:={5..7}; img[8]:={5..7};
img[9]:={5..7}; img[10]:={5..7}; img[11]:={5..7}; img[12]:={5..7};
img[13]:={5..7}; img[14]:={5..7}; img[15]:={};
downArrow:=NewPattern(img, 15, 15);
img[1]:={0, 4, 8, 12}; img[2]:={}; img[3]:={2, 6, 10, 14}; img[4]:={};
grey0:=NewPattern(img, 16, 4);
img[1]:={0, 2, 4, 6, 8, 10, 12, 14}; img[2]:={1, 3, 5, 7, 9, 11, 13, 15};
grey1:=NewPattern(img, 16, 2);
img[1]:={0, 1, 4, 5, 8, 9, 12, 13}; img[2]:={0, 1, 4, 5, 8, 9, 12, 13};
img[3]:={2, 3, 6, 7, 10, 11, 14, 15}; img[4]:={2, 3, 6, 7, 10, 11, 14, 15};
grey2:=NewPattern(img, 16, 4);
img[1]:={7}; img[2]:={7}; img[3]:={2, 7, 12}; img[4]:={3, 7, 11};
img[5]:={4, 7, 10}; img[6]:={5, 7, 9}; img[7]:={6..8}; img[8]:={0..6, 8..14};
img[9]:={6..8}; img[10]:={5, 7, 9}; img[11]:={4, 7, 10}; img[12]:={3, 7, 11};
img[13]:={2, 7, 12}; img[14]:={7}; img[15]:={7};
star:=NewPattern(img, 15, 15);
img[1]:={0}; img[2]:={}; img[3]:={}; img[4]:={};
img[5]:={}; img[6]:={}; img[7]:={}; img[8]:={};
img[9]:={}; img[10]:={}; img[11]:={}; img[12]:={};
img[13]:={}; img[14]:={}; img[15]:={}; img[16]:={};
ticks:=NewPattern(img, 32, 16)
END InitPat;
(* PROCEDURE InitPat;
VAR img: ARRAY 17 OF SET;
BEGIN
img[1]:={18}; img[2]:={17..19}; img[3]:={18..20}; img[4]:={19..21};
img[5]:={20..22}; img[6]:={21..23}; img[7]:={22..24}; img[8]:={23..25, 31};
img[9]:={24..26, 30, 31}; img[10]:={25..27, 29..31}; img[11]:={26..31}; img[12]:={27..31};
img[13]:={26..31}; img[14]:={25..31}; img[15]:={24..31};
arrow:=NewPattern(img, 15, 15);
img[1]:={24..31}; img[2]:={25..31}; img[3]:={26..31}; img[4]:={27..31};
img[5]:={28..31}; img[6]:={29..31}; img[7]:={30..31}; img[8]:={31};
hook:=NewPattern(img, 8, 8);
img[1]:={21, 31}; img[2]:={22, 30}; img[3]:={23, 29}; img[4]:={24, 28};
img[5]:={25, 27}; img[6]:={}; img[7]:={25, 27}; img[8]:={24, 28};
img[9]:={23, 29}; img[10]:={22, 30}; img[11]:={21, 31};
cross:=NewPattern(img, 11, 11);
img[1]:={25}; img[2]:={24..26}; img[3]:={23..27}; img[4]:={22..28};
img[5]:={21..29}; img[6]:={24..26}; img[7]:={24..26}; img[8]:={24..26};
img[9]:={24..26}; img[10]:={24..26}; img[11]:={24..26}; img[12]:={24..26};
img[13]:={24..26}; img[14]:={24..26}; img[15]:={};
downArrow:=NewPattern(img, 15, 15);
img[1]:={19, 23, 27, 31}; img[2]:={}; img[3]:={17, 21, 25, 29}; img[4]:={};
grey0:=NewPattern(img, 16, 4);
img[1]:={17, 19, 21, 23, 25, 27, 29, 31}; img[2]:={16, 18, 20, 22, 24, 26, 28, 30};
grey1:=NewPattern(img, 16, 2);
img[1]:={18, 19, 22, 23, 26, 27, 30, 31}; img[2]:={18, 19, 22, 23, 26, 27, 30, 31};
img[3]:={16, 17, 20, 21, 24, 25, 28, 29}; img[4]:={16, 17, 20, 21, 24, 25, 28, 29};
grey2:=NewPattern(img, 16, 4);
img[1]:={24}; img[2]:={24}; img[3]:={19, 24, 29}; img[4]:={20, 24, 28};
img[5]:={21, 24, 27}; img[6]:={22, 24, 26}; img[7]:={23..25}; img[8]:={17..23, 25..31};
img[9]:={23..25}; img[10]:={22, 24, 26}; img[11]:={21, 24, 27}; img[12]:={20, 24, 28};
img[13]:={19, 24, 29}; img[14]:={24}; img[15]:={24};
star:=NewPattern(img, 15, 15);
img[1]:={31}; img[2]:={}; img[3]:={}; img[4]:={};
img[5]:={}; img[6]:={}; img[7]:={}; img[8]:={};
img[9]:={}; img[10]:={}; img[11]:={}; img[12]:={};
img[13]:={}; img[14]:={}; img[15]:={}; img[16]:={};
ticks:=NewPattern(img, 32, 16)
END InitPat;*)
BEGIN Unit:=10000; Width:=Macintosh.thePortW; Height:=Macintosh.thePortH; UBottom:=-Macintosh.shadowH; InitPat
END Display.